<%@ page import="com.tlb.ejb.*,com.tlb.dto.*,com.tlb.web.*,java.util.*" %>



<%
Util util = Util.getUtil();
Poster p = new AuthManager(request, response).softAuthenticatePoster();


int threadLimit = 100;
int pageNo = 0;

try {
    pageNo = Integer.parseInt(request.getParameter("page"));
} catch (Exception x) {
    pageNo = 0;
}


Cookie[] cookies = request.getCookies();
HashMap marks = new HashMap();
if (cookies != null) {
    for (int c = 0; c < cookies.length; c++) {
        if ("marks".equals(cookies[c].getName())) {
            StringTokenizer st = new StringTokenizer(cookies[c].getValue(), ",");
            while (st.hasMoreTokens())
                marks.put(st.nextToken(), 1);
        }
    }
}

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
    	<meta http-equiv="expires" content="0">
    	<meta http-equiv="pragma" content="no-cache">
        <title>Big<%=Util.getUtil().getBoard(request) == Util.BCB ? "College" : "Law"%>Board.com</title>
        <link rel="shortcut icon" href="ext/c_sailboat.gif">
        <link rel="stylesheet" type="text/css" href="ext/tlbStyle.css" />
        <script type="text/javascript" src="ext/ajax.js"></script>
        <script type="text/javascript" src="ext/tlbMenu.js" />
        <script type="text/javascript">
            window.onload = initLeftMenu;
        </script>
        <script>
            function voidcb(d) {
            }
            function delC(id) {
                document.getElementById('c' + id).innerHTML="<img onclick='javascript: addC(\"" + id + "\")' src=ext/graydot.gif>";
                sendCookAjax("action=del&delC=" + id, voidcb);
            }
            
            function addC(id) {
                document.getElementById('c' + id).innerHTML="<img onclick='javascript: delC(\"" + id + "\")' src=ext/reddot.gif>";
                sendCookAjax("action=add&addC=" + id, voidcb);
            }
            
            function admFlagPost(postId, flagId) {                
                document.getElementById('admf' + postId).innerHTML="Done.";
                sendAjax("action=flagPost&adm=true&threadId=" + postId + "&postId=" + postId + "&flagId=" + flagId, voidcb);
            }
            
            
            
            
        </script>
    </head>
    
    <body onload="initLeftMenu()">
        <center>
            <div id="mainContainer"> 
                <table>                    
                <tr>
                    <td valign="top">
                        <div id="contentContainer" style="background-color:#FFFFFF">
                            <table border="0" cellpadding="0" cellspacing="0" width="500">
                            <tr>
                                <td colspan="3">
                                    
                                    <%@ include file="header.jsp" %>
                                    
                                    <br/>
                                    <form action="index.jsp" name="searchForm" method="GET">
                                        <input size="15" name="q" value="<%=request.getParameter("q") == null ? "" : request.getParameter("q").trim()%>" />
                                        <input type="submit" value="Search" class="btn" />
                                        &nbsp;&nbsp;
                                        <a href="/blb/advSearch.jsp" style="text-decoration: none"><font color="black">(Advanced Search...)</font></a>
                                    </form>
                                    <br />
                                </td>
                            </tr>
                                    
             <%
            ThreadDAO t = new ThreadDAO();
            List list = null;
            if (request.getParameter("q") != null && request.getParameter("q").trim().length() > 2) {
                list = t.searchThreads((p == null ? 0 : p.getPosterId()), threadLimit, request.getParameter("q").trim());
            } else {
                list = t.getTopThreads((p == null ? 0 : p.getPosterId()), threadLimit, pageNo);
            }
            if (list == null) {
                %><br>No results for search: <%=request.getParameter("q")%><%
            } else {
                for (Iterator it = list.iterator(); it.hasNext();) {
                    ThreadList thread = (ThreadList) it.next();
                    if(thread.isHidden(p))
                        continue;
                    
                    if (thread.getPower() != 0) {
                        thread.setTitle("[" + thread.getPower() + "] " + thread.getTitle());
                    }
                    thread.setTitle(new MonikerDAO().fixHTML(thread.getTitle()));

                    if (thread.getTitle() != null && thread.getTitle().length() > 35 && (thread.getTitle().indexOf(" ") == -1 || thread.getTitle().indexOf(" ") > 35)) {
                        thread.setTitle(thread.getTitle().substring(0, 35) + "<br>" + thread.getTitle().substring(35));
                    }

                    
                    %>
                    <tr class="<%=thread.getHidenReasonCSSClass(p)%>">
                        <td>
                        
                        <%if(p != null && p.getUserLevelId()==1) { %>
                            <span id="admf<%=thread.getThreadId()%>">
                                <img src="ext/nsfwdot.gif" title="NSFW" onclick="admFlagPost(<%=thread.getThreadId()%>, 4)">
                                <img src='ext/tosdot.gif' title='TOS' onclick="admFlagPost(<%=thread.getThreadId()%>, 5)">
                                <img src="ext/spamdot.gif" title="SPAM" onclick="admFlagPost(<%=thread.getThreadId()%>, 3)">
                            </span>
                        <%}%>


                        <%= marks.containsKey(thread.getThreadId() + "")
                        ? "<span id='c" + thread.getThreadId() + "'><img title='Watch' onclick='javascript: delC(\"" + thread.getThreadId() + "\")' src=ext/reddot.gif></span>"
                        : "<span id='c" + thread.getThreadId() + "'><img title='Watch' onclick='javascript: addC(\"" + thread.getThreadId() + "\")' src=ext/graydot.gif></span>"%>
                        


                        <a href='viewThread.jsp?threadId=<%=thread.getThreadId()%>&x=<%=thread.getThreadCount()%>'><%=thread.getTitle()%></a></td><td>&nbsp;&nbsp;&nbsp;<%=thread.getLastPostString()%></td><td>&nbsp;(<%=thread.getThreadCount()%>)</td></tr>      
                <%}
            }%>
                                    
            <tr><td colspan="3"><p></p><%= (list != null && threadLimit == list.size()) ? "<a href=index.jsp?page=" + (pageNo + 1) + "><font color=black>Go To Page " + (pageNo + 2) + "</font></a>" : "" %></td></tr>
            </TABLE>
        </div>
     </td>
     <td valign="top">
     	
        <%@ include file="menu.jsp" %>
     </td>
</tr>
</table>
<br><br>
</div>



<!-- Start of StatCounter Code -->
<script type="text/javascript">
    var sc_project=2753481; 
    var sc_invisible=0; 
    var sc_partition=27; 
    var sc_security="fadeb289"; 
</script>
<script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a class="statcounter" href="http://www.statcounter.com/"><img class="statcounter" src="http://c28.statcounter.com/2753481/0/fadeb289/0/" alt="blog stats" /></a></div></noscript>
<!-- End of StatCounter Code -->
        </center>
    </body>
</html>